home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Paste Exception.2 < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  1.4 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Paste Exception
  2. Sent:        6/11/96 3:56 PM
  3. Received:    6/11/96 4:08 PM
  4. From:        Mary Boetcher, mary_boetcher@quickmail.apple.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. Mail*LinkĀ® SMTP               Re>>Paste Exception
  9.  
  10. >>So I don't know if I should post an error dialog when I encounter the error
  11. >>and throw some standard exception to have the command aborted, or if I
  12. >>should really define my own exception class and make sure I catch it
  13. >>myself. In the latter case, where do I catch it and what do I do
  14. >>thereafter.
  15.  
  16. ODF code contains a couple of examples of putting up an alert after catching an exception. See the FW_CPrintHandler methods HandlePageSetup and HandlePrint.
  17.  
  18. In the case of a Paste command, any exceptions that occur will be caught in FW_CCommand::Execute. To catch the exception yourself, you could override FW_CClipboardCommand::Paste and add your own Try block, like this:
  19.  
  20. FW_Boolean CMyClipboardCommand::Paste(Environment* ev)
  21. {
  22.     FW_Boolean result = false;
  23.     FW_VOLATILE(result);
  24.  
  25.     FW_TRY()
  26.     {
  27.         result = FW_CClipboardCommand::Paste(ev);
  28.     }
  29.     FW_CATCH_BEGIN
  30.     FW_CATCH_EVERYTHING()
  31.     {
  32.   // Put up an alert or something
  33.         result = false;
  34.         // don't rethrow because we're handling the exception here;
  35.         // just return false
  36.     }
  37.     FW_CATCH_END
  38.  
  39.     return result;
  40. }
  41.  
  42. Mary Boetcher
  43. ODF Person
  44.